﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>学院信息</title>
    <link href="${pageContext.request.contextPath}/resources/bootstrap5/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons - 本地版本 -->
    <link href="${pageContext.request.contextPath}/resources/bootstrap-icons/1.11.3/bootstrap-icons.css" rel="stylesheet">
    <!-- Bootstrap Icons - 备用CDN -->
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <!-- 第二个备用CDN -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <style>
        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
            background: #f5f7fa;
            margin: 0;
            padding: 0;
        }
        .header {
            background: #2196f3;
            color: #fff;
            padding: 0 32px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 56px;
            box-shadow: 0 2px 8px rgba(33,150,243,0.08);
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
        }
        .header-left {
            display: flex;
            align-items: center;
        }
        .header-logo {
            width: 36px;
            height: 36px;
            margin-right: 12px;
        }
        .header-title {
            font-size: 1.4rem;
            font-weight: bold;
            letter-spacing: 1px;
        }
        .header-nav {
            margin-left: 32px;
            font-size: 1rem;
        }
        .header-nav a {
            color: #fff;
            text-decoration: none;
            margin-right: 16px;
            opacity: 0.85;
        }
        .header-nav a.active, .header-nav a:hover {
            opacity: 1;
            font-weight: bold;
        }

        .sidebar {
            position: fixed;
            top: 56px;
            left: 0;
            bottom: 0;
            width: 220px;
            background: #fff;
            box-shadow: 2px 0 8px rgba(33,150,243,0.06);
            overflow-y: auto;
            z-index: 100;
            padding-top: 16px;
        }
        .sidebar-menu {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .sidebar-menu > li {
            margin-bottom: 4px;
        }
        .sidebar-menu > li > a {
            display: flex;
            align-items: center;
            padding: 10px 24px;
            color: #333;
            text-decoration: none;
            border-radius: 8px 0 0 8px;
            transition: background 0.2s, color 0.2s;
            font-size: 1rem;
        }
        .sidebar-menu > li > a:hover, .sidebar-menu > li > a.active {
            background: #e3f2fd;
            color: #2196f3;
            font-weight: bold;
        }
        .sidebar-menu > li > a i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 1.1rem;
        }
        .sidebar-submenu {
            list-style: none;
            padding-left: 40px;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }
        .sidebar-menu > li.open .sidebar-submenu {
            max-height: 500px;
        }
        .sidebar-submenu > li > a {
            display: block;
            padding: 7px 0;
            color: #666;
            text-decoration: none;
            transition: color 0.2s;
            font-size: 0.98rem;
        }
        .sidebar-submenu > li > a:hover, .sidebar-submenu > li > a.active {
            color: #2196f3;
            font-weight: 500;
        }
        .content {
            margin-left: 240px;
            padding: 80px 32px 32px;
        }
        .card {
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 2px 12px rgba(33,150,243,0.07);
            margin-bottom: 24px;
            border: none;
        }
        .card-body {
            padding: 24px 24px 16px 24px;
        }
        .search-bar {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 18px;
        }
        .search-bar input {
            border-radius: 8px;
            border: 1px solid #e3e3e3;
            padding: 6px 14px;
            font-size: 1rem;
            width: 220px;
        }
        .search-bar .btn {
            border-radius: 8px;
            font-size: 1rem;
            padding: 6px 18px;
            font-weight: 500;
            box-shadow: none;
        }
        .btn-primary {
            background: #2196f3;
            border: none;
        }
        .btn-primary:hover {
            background: #1976d2;
        }
        .table {
            background: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(33,150,243,0.04);
        }
        .table thead th {
            background: #f5f7fa;
            color: #2196f3;
            font-weight: bold;
            text-align: center;
            border-bottom: 2px solid #e3e3e3;
        }
        .table tbody tr {
            transition: background 0.2s;
        }
        .table tbody tr:hover {
            background: #f1f8ff;
        }
        .table td, .table th {
            vertical-align: middle !important;
            text-align: center;
        }
        .pagination {
            justify-content: center;
            margin-top: 12px;
        }
        .pagination .page-item .page-link {
            border-radius: 6px !important;
            margin: 0 2px;
            color: #2196f3;
            border: none;
            background: #fff;
            font-weight: 500;
            transition: background 0.2s, color 0.2s;
        }
        .pagination .page-item.active .page-link {
            background: #2196f3;
            color: #fff;
            font-weight: bold;
            border: none;
        }
        .pagination .page-link:hover {
            background: #e3f2fd;
            color: #2196f3;
        }
        .form-control {
            border-radius: 8px;
            border: 1px solid #e3e3e3;
        }

        /* 用户名下拉菜单样式 */
        .header-user {
            display: flex;
            align-items: center;
            position: relative;
        }
        .header-user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            margin-right: 8px;
            object-fit: cover;
            background: #fff;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .header-user-avatar:hover {
            transform: scale(1.1);
        }
        .header-user-name {
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .user-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            min-width: 160px;
            z-index: 1001;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s ease;
            margin-top: 8px;
        }
        .user-dropdown.show {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        .user-dropdown::before {
            content: '';
            position: absolute;
            top: -6px;
            right: 20px;
            width: 12px;
            height: 12px;
            background: #fff;
            transform: rotate(45deg);
            box-shadow: -2px -2px 4px rgba(0,0,0,0.1);
        }
        .user-dropdown-item {
            display: flex;
            align-items: center;
            padding: 12px 16px;
            color: #333;
            text-decoration: none;
            transition: background 0.2s;
            border-bottom: 1px solid #f0f0f0;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .user-dropdown-item:last-child {
            border-bottom: none;
        }
        .user-dropdown-item:hover {
            background: #f8f9fa;
            color: #2196f3;
        }
        .user-dropdown-item i {
            margin-right: 8px;
            width: 16px;
            text-align: center;
        }

        @media (max-width: 900px) {
            .content {
                margin-left: 0;
                padding: 80px 10px 10px;
            }
            .sidebar {
                width: 100%;
                position: static;
                box-shadow: none;
            }
            .search-bar {
                flex-wrap: wrap;
            }
            .search-bar input {
                min-width: 150px;
            }
        }
    </style>
</head>
<body>
<!-- 顶部导航栏 -->
<div class="header">
    <div class="header-left">
        <img src="${pageContext.request.contextPath}/resources/images/logo.png" alt="Logo" class="header-logo">
        <span class="header-title">教务管理系统</span>
        <div class="header-nav">
            <a href="${pageContext.request.contextPath}/student/home">首页</a>
            <span style="opacity:0.5;">/</span>
            <a href="#" class="active">学院信息</a>
        </div>
    </div>

    <!-- 用户名下拉菜单 -->
    <div class="header-user" id="userDropdownContainer">
        <img src="${pageContext.request.contextPath}/resources/images/baimao.png" class="header-user-avatar" alt="用户头像" id="userAvatar">
        <span class="header-user-name" id="userName">
            <c:choose>
                <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.realName}">
                    ${sessionScope.loggedInUser.realName}
                </c:when>
                <c:when test="${not empty sessionScope.loggedInUser and not empty sessionScope.loggedInUser.username}">
                    ${sessionScope.loggedInUser.username}
                </c:when>
                <c:otherwise>
                    学生
                </c:otherwise>
            </c:choose>
        </span>
        <div class="user-dropdown" id="userDropdown">
            <a href="#" class="user-dropdown-item" onclick="showProfileModal()">
                <i class="bi bi-person-circle"></i>
                个人信息
            </a>
            <a href="${pageContext.request.contextPath}/student/changePassword" class="user-dropdown-item">
                <i class="bi bi-key"></i>
                修改密码
            </a>
            <a href="${pageContext.request.contextPath}/user/logout" class="user-dropdown-item">
                <i class="bi bi-box-arrow-right"></i>
                退出系统
            </a>
        </div>
    </div>
</div>

<!-- 侧边栏 -->
<div class="sidebar">
    <ul class="sidebar-menu">
        <li>
            <a href="${pageContext.request.contextPath}/student/home" class="active">
                <i class="bi bi-house-door"></i> 学生首页
            </a>
        </li>
        <li>
            <a href="#" class="has-submenu" onclick="toggleSubmenu(this)">
                <i class="bi bi-megaphone"></i> 通知公告
                <i class="bi bi-chevron-down ms-auto"></i>
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/student/notifications/academic">教务通知</a></li>
                <li><a href="${pageContext.request.contextPath}/student/notifications/exam">考试安排</a></li>
                <li><a href="${pageContext.request.contextPath}/student/notifications/classroom">教室安排</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu" onclick="toggleSubmenu(this)">
                <i class="bi bi-building"></i> 院系管理
                <i class="bi bi-chevron-down ms-auto"></i>
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/student/college">学院管理</a></li>
                <li><a href="${pageContext.request.contextPath}/student/major">专业管理</a></li>
                <li><a href="${pageContext.request.contextPath}/student/class">班级管理</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu" onclick="toggleSubmenu(this)">
                <i class="bi bi-book"></i> 课程管理
                <i class="bi bi-chevron-down ms-auto"></i>
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/student/courses">课程管理</a></li>
                <li><a href="${pageContext.request.contextPath}/student/my-courses">我的课程</a></li>
                <li><a href="${pageContext.request.contextPath}/student/schedule">我的课表</a></li>
                <li><a href="${pageContext.request.contextPath}/student/grades">成绩管理</a></li>
                <li><a href="${pageContext.request.contextPath}/student/evaluation">课程评价</a></li>
            </ul>
        </li>
        <li>
            <a href="#" class="has-submenu" onclick="toggleSubmenu(this)">
                <i class="bi bi-clipboard-check"></i> 教学管理
                <i class="bi bi-chevron-down ms-auto"></i>
            </a>
            <ul class="sidebar-submenu">
                <li><a href="${pageContext.request.contextPath}/student/leave">请假管理</a></li>
                <li><a href="${pageContext.request.contextPath}/student/homework">作业提交</a></li>
                <li><a href="${pageContext.request.contextPath}/student/attendance">考勤管理</a></li>
            </ul>
        </li>
    </ul>
</div>

<!-- 主内容区 -->
<div class="content">
    <!-- 错误信息显示 -->
    <c:if test="${not empty error}">
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <i class="bi bi-exclamation-triangle"></i> ${error}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    </c:if>

    <div class="card">
        <div class="card-body">
            <h5 class="card-title mb-3">
                <i class="bi bi-buildings text-primary"></i> 学院信息
            </h5>

            <!-- 搜索栏 -->
            <form method="get" action="${pageContext.request.contextPath}/student/college">
                <div class="search-bar">
                    <input type="text" name="nameSearch" class="form-control" placeholder="请输入学院名称"
                           value="${nameSearch}">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-search"></i> 搜索
                    </button>
                    <c:if test="${not empty nameSearch}">
                        <a href="${pageContext.request.contextPath}/student/college" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-clockwise"></i> 重置
                        </a>
                    </c:if>
                </div>
            </form>

            <!-- 数据表格 -->
            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr>
                        <th style="width: 10%;">序号</th>
                        <th style="width: 30%;">学院名称</th>
                        <th style="width: 60%;">学院描述</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:choose>
                        <c:when test="${not empty colleges}">
                            <c:forEach items="${colleges}" var="college" varStatus="status">
                                <tr>
                                    <td>${(currentPage - 1) * pageSize + status.index + 1}</td>
                                    <td style="text-align: left; font-weight: 500;">
                                            ${college.name}
                                    </td>
                                    <td style="text-align: left;">
                                        <c:choose>
                                            <c:when test="${not empty college.description}">
                                                ${college.description}
                                            </c:when>
                                            <c:otherwise>
                                                <span class="text-muted">暂无描述</span>
                                            </c:otherwise>
                                        </c:choose>
                                    </td>
                                </tr>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                            <tr>
                                <td colspan="3" class="text-center text-muted py-4">
                                    <i class="bi bi-building" style="font-size: 2rem;"></i>
                                    <br>暂无学院信息数据
                                </td>
                            </tr>
                        </c:otherwise>
                    </c:choose>
                    </tbody>
                </table>
            </div>

            <!-- 分页 -->
            <c:if test="${totalPages > 1}">
                <nav aria-label="Page navigation">
                    <ul class="pagination justify-content-center">
                        <c:if test="${currentPage > 1}">
                            <li class="page-item">
                                <a class="page-link" href="?page=${currentPage - 1}&size=${pageSize}<c:if test='${not empty nameSearch}'>&nameSearch=${nameSearch}</c:if>" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                        </c:if>

                        <c:forEach begin="1" end="${totalPages}" var="i">
                            <li class="page-item ${i == currentPage ? 'active' : ''}">
                                <a class="page-link" href="?page=${i}&size=${pageSize}<c:if test='${not empty nameSearch}'>&nameSearch=${nameSearch}</c:if>">
                                        ${i}
                                </a>
                            </li>
                        </c:forEach>

                        <c:if test="${currentPage < totalPages}">
                            <li class="page-item">
                                <a class="page-link" href="?page=${currentPage + 1}&size=${pageSize}<c:if test='${not empty nameSearch}'>&nameSearch=${nameSearch}</c:if>" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </c:if>
                    </ul>
                    <div class="text-left mt-2" style="font-size:0.98rem;color:#888;">
                        共 ${totalRecords} 条
                    </div>
                </nav>
            </c:if>
        </div>
    </div>
</div>

<!-- 个人信息模态框 -->
<div class="modal fade" id="profileModal" tabindex="-1" aria-labelledby="profileModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content" style="border-radius: 12px;">
            <div class="modal-header" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 12px 12px 0 0;">
                <h5 class="modal-title" id="profileModalLabel">
                    <i class="bi bi-person-circle"></i> 个人信息
                </h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body" style="padding: 30px;">
                <c:if test="${not empty currentStudent}">
                    <div class="row mb-4">
                        <div class="col-12 text-center">
                            <div style="width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 15px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; align-items: center; justify-content: center; color: white; font-size: 2rem;">
                                <i class="bi bi-person-circle"></i>
                            </div>
                            <h5 class="mb-1">
                                <c:choose>
                                    <c:when test="${not empty currentStudent.user.realName}">
                                        ${currentStudent.user.realName}
                                    </c:when>
                                    <c:otherwise>
                                        学生信息
                                    </c:otherwise>
                                </c:choose>
                            </h5>
                            <p class="text-muted mb-0">学生个人信息详情</p>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-person me-2"></i>姓名</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.user.realName}">
                                            ${currentStudent.user.realName}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-card-text me-2"></i>学号</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.studentNo}">
                                            ${currentStudent.studentNo}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-person-badge me-2"></i>用户名</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.user.username}">
                                            ${currentStudent.user.username}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-gender-ambiguous me-2"></i>性别</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${currentStudent.gender == 1}">
                                            <span class="badge" style="background: #e3f2fd; color: #1976d2;">男</span>
                                        </c:when>
                                        <c:when test="${currentStudent.gender == 0}">
                                            <span class="badge" style="background: #fce4ec; color: #e91e63;">女</span>
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-building me-2"></i>班级</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.clazz and not empty currentStudent.clazz.name}">
                                            ${currentStudent.clazz.name}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未分配班级</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-mortarboard me-2"></i>专业</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.clazz and not empty currentStudent.clazz.major and not empty currentStudent.clazz.major.name}">
                                            ${currentStudent.clazz.major.name}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未分配专业</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-bank me-2"></i>学院</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.clazz and not empty currentStudent.clazz.major and not empty currentStudent.clazz.major.college and not empty currentStudent.clazz.major.college.name}">
                                            ${currentStudent.clazz.major.college.name}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未分配学院</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-envelope me-2"></i>电子邮箱</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.email}">
                                            ${currentStudent.email}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div style="padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #667eea;">
                                <strong style="color: #667eea;"><i class="bi bi-telephone me-2"></i>联系电话</strong>
                                <div class="mt-1">
                                    <c:choose>
                                        <c:when test="${not empty currentStudent.phone}">
                                            ${currentStudent.phone}
                                        </c:when>
                                        <c:otherwise>
                                            <span class="text-muted">未设置</span>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>
                    </div>
                </c:if>

                <c:if test="${empty currentStudent}">
                    <div class="text-center py-5">
                        <i class="bi bi-exclamation-circle text-warning" style="font-size: 3rem;"></i>
                        <h5 class="mt-3">无法获取学生信息</h5>
                        <p class="text-muted">请联系管理员或重新登录</p>
                    </div>
                </c:if>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                <a href="${pageContext.request.contextPath}/student/changePassword" class="btn" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white;">
                    <i class="bi bi-key me-1"></i>修改密码
                </a>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/resources/bootstrap5/js/bootstrap.bundle.min.js"></script>
<script>
    // 用户名下拉菜单
    document.getElementById('userDropdownContainer').addEventListener('click', function(e) {
        e.stopPropagation();
        const dropdown = document.getElementById('userDropdown');
        dropdown.classList.toggle('show');
    });

    // 点击其他地方关闭下拉菜单
    document.addEventListener('click', function() {
        const dropdown = document.getElementById('userDropdown');
        dropdown.classList.remove('show');
    });

    // 侧边栏子菜单切换
    function toggleSubmenu(element) {
        const parent = element.parentElement;
        const submenu = parent.querySelector('.sidebar-submenu');

        // 关闭其他打开的子菜单
        document.querySelectorAll('.sidebar-menu > li').forEach(li => {
            if (li !== parent) {
                li.classList.remove('open');
            }
        });

        // 切换当前子菜单
        parent.classList.toggle('open');
    }

    // 显示个人信息模态框
    function showProfileModal() {
        // 关闭用户名下拉菜单
        const dropdown = document.getElementById('userDropdown');
        dropdown.classList.remove('show');

        // 显示模态框
        const modal = new bootstrap.Modal(document.getElementById('profileModal'));
        modal.show();
    }

    // 移动端侧边栏切换按钮
    document.addEventListener('DOMContentLoaded', function() {
        const sidebar = document.querySelector('.sidebar');
        const toggleButton = document.createElement('button');

        toggleButton.innerHTML = '<i class="bi bi-list"></i>';
        toggleButton.className = 'btn btn-primary fixed-top';
        toggleButton.style.top = '60px';
        toggleButton.style.left = '10px';
        toggleButton.style.zIndex = '101';
        toggleButton.style.display = 'none';

        document.body.appendChild(toggleButton);

        toggleButton.addEventListener('click', function() {
            sidebar.classList.toggle('active');
        });

        function checkScreenSize() {
            if (window.innerWidth < 768) {
                toggleButton.style.display = 'block';
            } else {
                toggleButton.style.display = 'none';
                sidebar.classList.remove('active');
            }
        }

        window.addEventListener('resize', checkScreenSize);
        checkScreenSize();
    });
</script>
</body>
</html>

